package com.example.demo.stumanage.controller;

import com.supconit.ticc.stumanage.domain.Clazz;
import com.supconit.ticc.stumanage.domain.Student;
import com.supconit.ticc.stumanage.domain.Tree;
import com.supconit.ticc.stumanage.domain.TreeNode;
import com.supconit.ticc.stumanage.service.ZtreeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.ArrayList;
import java.util.List;

@Controller
@RequestMapping("zTree")
public class ZtreeController {

    @Autowired
    private ZtreeService ztreeService;

 /*   @ResponseBody
    @RequestMapping("/initData")
    public List initTreeData(){
        List<Tree> treeList = new ArrayList<Tree>();
        for(int i=1;i<10;i++){
            Tree tree1 = new Tree(String.valueOf(0),String.valueOf(i),"一级菜单"+i);
            treeList.add(tree1);
            for(int j=1;j<10;j++){
                Tree tree2 = new Tree(String.valueOf(i),String.valueOf(i)+String.valueOf(j),"二级菜单"+String.valueOf(i)+String.valueOf(j));
                treeList.add(tree2);
                for(int z=1;z<10;z++){
                    Tree tree3 = new Tree(String.valueOf(i)+String.valueOf(j),String.valueOf(i)+String.valueOf(j)+String.valueOf(z),"三级节点"+String.valueOf(i)+String.valueOf(j)+String.valueOf(z));
                    treeList.add(tree3);
                }
            }
        }
*//*        Tree tree1 = new Tree(String.valueOf(0),String.valueOf(1),"test1");
        Tree tree2 = new Tree(String.valueOf(1),String.valueOf(11),"test11");
        Tree tree3 = new Tree(String.valueOf(1),String.valueOf(12),"test11");
        Tree tree4 = new Tree(String.valueOf(11),String.valueOf(111),"test111");
        treeList.add(tree1);
        treeList.add(tree2);
        treeList.add(tree3);
        treeList.add(tree4);*//*
        return treeList;
    }*/

    @ResponseBody
    @RequestMapping("/initData")
    public List< ? super TreeNode> buildTree(){
        return this.ztreeService.buildTree();
    }

    @ResponseBody
    @RequestMapping("/asynchInitData")
    public List< ? super TreeNode> asynchBuildTree(String treeId,String isParent){
        return this.ztreeService.asynchBuildTree(treeId,isParent);
    }

}
